<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <title>作用域插槽</title>
</head>
<body>
    <!-- 提出原因：让  插槽内容  访问到 子组件  的内容-->
<div id="app">
    <current-user>
        <!-- 我们可以给 v-slot 带一个值来定义我们提供的插槽 prop 的名字 -->
        <template v-slot:default="slotScope">
            {{slotScope.user.lastName}}
        </template>
    </current-user>
</div>

<script>
     Vue.component('current-user', {
         data: function() {
            return {
                user: {
                    firstName:'firstName',
                    lastName: 'lastName'
                }
            }
        },
        template: `
           <div>
                <span>插槽部分</span>
                <slot v-bind:user='user' name='default'>{{ user.firstName}}</slot>
           </div>
        `
    })
    new Vue({
        el: '#app',
        data: function (){
            return {
            
            }
        }
    })


</script>
</body>
</html>